package com.skycong.hello77.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.Toast;
import com.skycong.hello77.R;

/*
* 创建和使用fragment的步骤
*   1,创建子类继承fragment
*   2,重写onCreateView()方法，该方法主要定义fragment的布局，以view对象的形式返回fragment的视图
*   3，将fragment引入到Activity中
*
* */
public class TitleFragment extends Fragment implements View.OnClickListener{
    private RelativeLayout relativeLayout;
    /*
    * LayoutInflater inflater 布局填充器或者加载器，将XML文件转换成view对象
    * ViewGroup container 表当前fragment插入activity的布局视图对象
    * Bundle savedInstanceState表示存储上一个fragment的信息
    * */
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        //LayoutInflater inflater 布局填充器或者加载器，将XML文件转换成view对象
        View view = inflater.inflate(R.layout.fragment_title, null);
        relativeLayout = (RelativeLayout) view.findViewById(R.id.relativeLayout);
        relativeLayout.setOnClickListener(this);

        return view;
    }

    @Override
    public void onClick(View view) {
        Toast.makeText(getActivity(),"我是标题栏",Toast.LENGTH_LONG).show();
    }
}
